<template>
	<view class="ss-flex" :style="{ height: data.height*2 + 'rpx' }">
		<view class="swiperBox" :style="[radiusStyle,{height:'100%',flex:data.leftRatio}]">
		  <su-swiper
			:list="imgList"
			:dotStyle="dotMap[data.indicator]"
			imageMode="scaleToFill"
			:autoplay="true"
			:height="data.height*2 "
			dotCur="bg-mask-40"
			:seizeHeight="210"
			:styles="props.styles"
		  />
		</view>
		<view class="ss-flex-col ss-row-between ss-m-l-10" 
			:style="{height:'100%',flex:data.rightRatio, marginLeft: data.space*2 + 'rpx'}">
			<image :src="sheep.$url.cdn(props.data.menu1,'ygb')" mode="scaleToFill" 
				:style="[radiusStyle,{width: '100%',flex:data.rightTop}]" 
        @click="navGo(props.data.menu1link,props.data?.mp1)" />
			<image :src="sheep.$url.cdn(props.data.menu2,'ygb')"  mode="scaleToFill" 
				:style="[radiusStyle,{ width: '100%',flex:data.rightBottom,marginTop:data.space*2 + 'rpx'}]" 
        @click="navGo(props.data.menu2link,props.data?.mp2)" />
		</view>
	</view>
<!-- 	<view class="ai" v-if="data.aiShow=='1'"  @click="navGo(data.aiUrl)">
		<image :src="sheep.$url.cdn(data.aiImg)" style="width:100%;height:100%;"></image>
	</view> -->
</template>

<script setup>
  import { computed, onMounted } from 'vue';
  import sheep from '@/sheep';
import { showAuthModal } from '@/sheep/hooks/useModal';

  const dotMap = {
    1: 'long',
    2: 'tag',
  };
  const props = defineProps({
    data: {
      type: Object,
      default: () => ({}),
    },
    styles: {
      type: Object,
      default: () => ({}),
    },
  });
	const radiusStyle = computed(()=>{
		return {
			'border-radius': props.data.radius*2 + 'rpx',
		}
	})
  const imgList = computed(() =>
	
    props.data.list.map((item) => ({
      ...item,
      src: sheep.$url.cdn(item.src),
      poster: sheep.$url.cdn(item.poster),
    })),
  );
  
  
  function navGo(url,mp){
	  
	  if(!sheep.$store('user').isLogin){
		  showAuthModal();
		  return;
	  }
	  // #ifdef MP-WEIXIN
	  if(mp.isMp){
		  uni.navigateToMiniProgram({
			appId: mp.appid,
			path: mp.path,
			envVersion:'release',
			complete(res) {
			  // 打开成功
			  console.log('navigateToMiniProgram',res);
			},
		  });
	  }else{
		  sheep.$router.go(url)
	  }
	  // #endif
	  // #ifdef APP
	  plus.share.getServices(res1 => {
	    var is_weixin = res1.find(i => i.id === 'weixin');
	    if (is_weixin) {
	      is_weixin.launchMiniProgram({
	        id: mp.appid,
	        path: '/pages/index/home' //要打开小程序的路径
	      }, res2 => {
	        console.log(JSON.stringify(res2));
	        //成功
	      }, err => {
	        //失败
			console.log('err2',err);
	      })
	    }else{
			console.log('没有wx');
		}
	  }, err => {
	    console.log('err1',err);
	  })
	  // #endif
	  // #ifdef H5
	  sheep.$router.go(url)
	  // #endif
  }
  
  onMounted(()=>{
	  // console.log('props.data:',props.data);
  })
  
</script>

<style lang="scss" scoped>
	.swiperBox{
		overflow: hidden;
	}
	.ai{
		width:120rpx;
		height:150rpx;
		position:fixed;
		right:20rpx;
		z-index:10000;
		bottom:500rpx;
	}
</style>
